package day4;

import java.util.Scanner;
/*
4-2
给定一个十进制数M，以及需要转换的进制数N。将十进制数M转化为N进制数
 */
public class TestDemo6 {
    public static void main(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();
        Scanner scanner = new Scanner(System.in);
        int a = 0;
        int M = scanner.nextInt();
        int N = scanner.nextInt();
        String table = "0123456789ABCDEF";
        boolean flg = false;
        if(M == 0) {
            stringBuilder.append('0');
        }
        if(M < 0) {
            M = -M;
            flg = true;
        }
        while (M != 0) {
            stringBuilder.append(table.charAt(M%N));
            M = M/N;
        }
        if(flg) {
            stringBuilder.append("-");
        }
        stringBuilder.reverse();
        System.out.println(stringBuilder);
    }
}
